package com.voilet.interview.rx.operator.filter;

import android.util.Log;

import com.voilet.interview.rx.operator.absOperator;

import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

/**
 * Created by kan212 on 2019/4/10.
 * take 是顺序，takelast刚好是反序的
 */

public class takeLast implements absOperator {
    @Override
    public void test() {
        Observable.just(1, 2, 3, 4, 5)
                .takeLast(3) //指定观察者只能接受被观察者发送的3个事件
                .subscribe(new Observer<Integer>() {
                    @Override
                    public void onSubscribe(Disposable d) {
                        Log.d(TAG, "开始采用subscribe连接");
                    }

                    @Override
                    public void onNext(Integer value) {
                        Log.d(TAG, "过滤后得到的事件是："+ value  );
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.d(TAG, "对Error事件作出响应");
                    }

                    @Override
                    public void onComplete() {
                        Log.d(TAG, "对Complete事件作出响应");
                    }
                });
    }

    @Override
    public void test2() {

    }
}
